package com.tomcat.utils;

/**
 * desc:
 *
 * @author tengfei wang
 * @version 1.0
 * @date Created in 23/9/2020
 */
public class HttpHeaderUtils {

    public static String httpStatus200(long contentLength) {
        StringBuilder builder = new StringBuilder();
        builder.append("HTTP/1.1 200 OK \n")
                .append("Content-Type: text/html; charset=utf-8 \n")
                .append("Content-Length: ").append(contentLength)
                .append("\n\r\n");
        return builder.toString();
    }

    public static String httpStatus404() {
        String content = "<h1>404 not fount</h1>";
        StringBuilder builder = new StringBuilder();
        builder.append("HTTP/1.1 404 not found \n")
                .append("Content-Type: text/html; charset=utf-8 \n")
                .append("Content-Length: ").append(content.getBytes().length)
                .append("\n\r\n")
                .append(content);
        return builder.toString();
    }
}
